import { editPageSqlConfig } from '@/services/wms-dev-tool/business-page-list';
import { useRequest } from '@@/plugin-request';
import { ModalForm, ProFormText } from '@ant-design/pro-components';
import { message } from 'antd';

const SqlConfigUpdateForm = (props: any) => {
  const { run } = useRequest(editPageSqlConfig, {
    manual: true,
    onSuccess: () => {
      props.handleUpdateFormOpen(false);
      props.ok();
    },
    onError: (error) => {
      message.error(error.message);
    },
  });
  return (
    <ModalForm
      initialValues={props.values}
      modalProps={{
        destroyOnClose: true,
      }}
      title={<span>编辑页面</span>}
      width="400px"
      open={props.updateFormOpen}
      onOpenChange={props.handleUpdateFormOpen}
      onFinish={async (value) => {
        run({
          ...props.values,
          ...value,
        });
      }}
    >
      <ProFormText
        name="code"
        width="md"
        disabled={false}
        label={<span>编码</span>}
        placeholder="请输入编码"
        rules={[
          {
            required: true,
            message: <span>编码是必填项</span>,
          },
        ]}
      />
      <ProFormText
        name="description"
        label={<span>描述信息</span>}
        width="md"
        placeholder="请输入描述信息"
        rules={[
          {
            required: true,
            message: <span>描述信息是必填项</span>,
          },
        ]}
      />
    </ModalForm>
  );
};

export default SqlConfigUpdateForm;
